package com.tomtom.amelinium.chartservice.serializer;

import com.tomtom.amelinium.chartservice.config.GoogleChartConfig;
import com.tomtom.amelinium.chartservice.model.ChartModel;
/**
 * Transforms chart model into HTML code that can be put in a tab.
 * 
 * @author Natasza Nowak
 * 
 */
public class TabsHTMLChartSerializer {
	/**
	 * Uses GoogleChartConfig and methods of JSPChartSerializer class to
	 * serialize chart model into HTML code with embedded JSP script code.
	 * 
	 * @return serialized version of the model.
	 */
	public String generateHTML(ChartModel chartModel){
		
		String result = "";
		
		JSPChartSerializer jspChartSerializer = new JSPChartSerializer();
				
		result += GoogleChartConfig.main_div;
		result += GoogleChartConfig.script_head;
		
		result += GoogleChartConfig.setter;
		
		result += GoogleChartConfig.configuration_head;
		result += jspChartSerializer.serializeConfiguration(chartModel.getChartConfig());
		result += GoogleChartConfig.configuration_tail;
		
		result += GoogleChartConfig.chart_head;
		result += jspChartSerializer.serializeChart(chartModel);
		result += GoogleChartConfig.chart_tail;
		
		result += GoogleChartConfig.roadmap_head;
		result += jspChartSerializer.serializeDateTable(chartModel.getRoadmap());
		result += GoogleChartConfig.roadmap_tail;
		
		result += GoogleChartConfig.log_head;
		result += jspChartSerializer.serializeLogTable(chartModel.getLogTable());
		result += GoogleChartConfig.log_tail;
		
		result += GoogleChartConfig.script_tail;
		
		return result;
	}
	
}
